<?php
namespace app\shouyin\model;

use think\Model;
use think\Db;
class ProductOrder extends Model
{
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    // 自动写入时间戳
    protected $autoWriteTimestamp = true;

    public function setGoodsAttr($value,$data)
    {
        return json_encode($data['goods']);
    }
    public function getGoodsAttr($value)
    {
        return json_decode($value);
    }
    public function getFinanceTextAttr($value,$data)
    {
        $admins = Db::name('system_user')->where('id',$data['finance_id'])->column('nick');
        return $admins;
    }
    public function getCashierTextAttr($value,$data)
    {
        $admins = Db::name('system_user')->where('id',$data['cashier_id'])->column('nick');
        return $admins;
    }
    public function hasShop()
    {
        return $this->hasOne('app\shop\model\Shop', 'id', 'shop_id');
    }
    public function hasUser()
    {
        return $this->hasOne('app\user\model\User', 'id', 'user_id');
    }

}
